package com.dxy.yesas2020goals.study.partone.disignpattern.prototypepattern;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.List;

/**
 * @author victorydeng
 * @Classname Prototype
 * @Description TODO
 * @Date 2020/3/1 13:26
 * @Created by victorydeng
 */
@Data
public class Prototype  implements Cloneable{
  private int id;

  private String name;

  private Integer number;

  private List<String> prossion;



  protected Prototype clone(Prototype source) {
    try {
      String jsonString= JSON.toJSONString(source);
      JSONObject voJson = JSONObject.parseObject(jsonString);
      Prototype prototype = JSON.toJavaObject(voJson, Prototype.class);
      return prototype;
    }catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
}
